import { reqCategoryList,reqGetBannerList,reqGetFloorList } from "@/api"
const state = {
    categoryList:[],
    bannerList:[],
    floorList:[]
}
const actions = {
    //通过api里面的接口函数，向服务器发请求，获取服务器的数据
    async getCategoryList(context){
        let result = await reqCategoryList();
        if(result.code === 200){
            context.commit('CATEGORYLIST',result.data)
        }
    },
    async getBannerList(context){
        let result = await reqGetBannerList();
        if(result.code === 200){
            context.commit('GETBANNERLIST',result.data)
        }
    },
    async getFloorList(context){
        let result = await reqGetFloorList();
        if(result.code === 200){
            context.commit('GETFLOORLIST',result.data)
        }
    }
}
const mutations = {
    CATEGORYLIST(state,categoryList){
        state.categoryList = categoryList
    },
    GETBANNERLIST(state,bannerList){
        state.bannerList = bannerList
    },
    GETFLOORLIST(state,floorList){
        state.floorList = floorList
    },
}
const getters = {}

export default ({
    state,
    actions,
    mutations,
    getters
})